﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:silvermap="clr-namespace:QUT.Bio.SilverMap"
             xmlns:util="clr-namespace:QUT.Bio.Util"
             x:Class="QUT.Bio.SilverMap.HorizontalLayout2"
             x:Name="UserControl"
             mc:Ignorable="d"
             d:DesignWidth="700"
             d:DesignHeight="700"
             SizeChanged="OnResize">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/QUT.Bio;component/SilverMap/Simple Styles.xaml" />
                <ResourceDictionary Source="/QUT.Bio;component/SilverMap/Theme.xaml" />
                <ResourceDictionary Source="/QUT.Bio;component/SilverMap/HorizontalLayoutStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Expander x:Name="alignmentExpander"
                  Header="Alignment"
                  ExpandDirection="Left"
                  IsExpanded="False"
                  Margin="0"
                  HorizontalAlignment="Left"
                  Panel.ZIndex="1"
                  d:LayoutOverrides="Width"
                  Style="{DynamicResource ExpanderStyleLeft}"
                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  MinWidth="0"
                  VerticalAlignment="Stretch"
                  Padding="0"
                  Grid.IsSharedSizeScope="True"
                  Collapsed="alignmentExpander_Collapsed"
                  MouseLeave="alignmentExpander_MouseLeave"
                  MouseEnter="alignmentExpander_MouseEnter">
            
            <Expander.Background>
                <LinearGradientBrush EndPoint="0.5,1"
                                     MappingMode="RelativeToBoundingBox"
                                     StartPoint="0.5,0">
                    <GradientStop Color="#FF9CC7EF"
                                  Offset="0" />
                    <GradientStop Color="White"
                                  Offset="1" />
                </LinearGradientBrush>
            </Expander.Background>
            
            <Grid x:Name="alignmentPanel"
                  Height="Auto"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                  ScrollViewer.VerticalScrollBarVisibility="Disabled"
                  Width="Auto"
                  Margin="0,0,0,10"
                  Background="{x:Null}"
                  MinWidth="100">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0*"
                                   MaxHeight="15"
                                   MinHeight="15" />
                    <RowDefinition Height="0*"
                                   MaxHeight="30"
                                   MinHeight="30" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock FontSize="16"
                           HorizontalAlignment="Center"
                           Grid.Row="1"
                           Margin="0,0,5,0">
                    <Run Text="Alignment" />
                </TextBlock>

                <silvermap:HitStack x:Name="alignment"
                                    ScrollViewer.VerticalScrollBarVisibility="Disabled"
                                    VerticalContentAlignment="Top"
                                    Margin="0,0,5,0"
                                    Grid.Row="2"
                                    MinHeight="0" />

                <ToggleButton x:Name="alignmentToggle"
                              Content=""
                              HorizontalAlignment="Right"
                              Margin="0,0,7,0"
                              Width="15"
                              Height="15"
                              Click="alignmentButton_Click"
                              VerticalAlignment="Top"
                              BorderThickness="2"
                              ToolTip="Lock/unlock panel" />
                
                <Thumb x:Name="alignmentThumb"
                       Margin="0"
                       DragDelta="Thumb_DragDelta"
                       Width="5"
                       Height="{Binding ActualHeight, ElementName=alignmentExpander}"
                       HorizontalAlignment="Right"
                       Grid.RowSpan="3"
                       Cursor="SizeWE"
                       HorizontalContentAlignment="Right"
                       VerticalContentAlignment="Stretch"
                       IsTabStop="False" />
            </Grid>
        </Expander>
        
        <Grid x:Name="mainPanel"
              VerticalAlignment="Stretch"
              HorizontalAlignment="Stretch"
              Grid.Column="0"
              Grid.ColumnSpan="1"
              Background="{x:Null}">
            
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition />
            </Grid.RowDefinitions>
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="alignmentColumn"
                                  Width="0" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition x:Name="summaryColumn"
                                  Width="0" />
            </Grid.ColumnDefinitions>

            <StackPanel x:Name="filterPanel"
                        Orientation="Horizontal"
                        Grid.Row="0"
                        Margin="10,5,40,5"
                        HorizontalAlignment="Left"
                        Grid.Column="1">

                <TextBlock Text="Query"
                           FontSize="12"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Left"
                           Margin="5,0"
                           Foreground="Black" />

                <silvermap:HistoryPanel x:Name="historyPanel"
                                        Margin="5,0"
                                        VerticalAlignment="Center"
                                        MinWidth="200" />

                <!-- Search functionality is not available in the present iteration. -->
                <TextBlock Text="Search"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Left"
                           Margin="10,0,5,0"
                           Foreground="Black"
                           Visibility="Collapsed" />

                <!-- Search functionality is not available in the present iteration. -->
                <silvermap:SearchControl x:Name="searchControl"
                                         Margin="5,0"
                                         VerticalAlignment="Center"
                                         MinWidth="200"
                                         HorizontalAlignment="Stretch"
                                         Visibility="Collapsed" />
            </StackPanel>
            
            <silvermap:View x:Name="view"
                            Grid.Row="1"
                            VerticalAlignment="Stretch"
                            Margin="10,5,10,10"
                            MinHeight="400"
                            Background="{x:Null}"
                            Grid.Column="1"  />
        </Grid>

        <Expander x:Name="summaryExpander"
                  Header="Summary"
                  ExpandDirection="Right"
                  IsExpanded="False"
                  Margin="0"
                  HorizontalAlignment="Right"
                  Grid.Column="2"
                  Panel.ZIndex="2"
                  d:LayoutOverrides="Width"
                  Style="{DynamicResource ExpanderStyleRight}"
                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  Collapsed="summaryExpander_Collapsed"
                  MouseLeave="summaryExpander_MouseLeave"
                  MouseEnter="summaryExpander_MouseEnter">

            <Expander.Background>
                <LinearGradientBrush EndPoint="0.5,1"
                                     StartPoint="0.5,0">
                    <GradientStop Color="#FF9CC7EF"
                                  Offset="0" />
                    <GradientStop Color="White"
                                  Offset="1" />
                </LinearGradientBrush>
            </Expander.Background>

            <Grid x:Name="summaryPanel"
                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  Margin="0,0,0,10"
                  MinWidth="350"
                  Width="350">
                
                <Grid.RowDefinitions>
                    <RowDefinition Height="0*"
                                   MaxHeight="15"
                                   MinHeight="15" />
                    <RowDefinition Height="0*"
                                   MaxHeight="30"
                                   MinHeight="30" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                
                <ToggleButton x:Name="summaryToggle"
                              Content=""
                              HorizontalAlignment="Left"
                              Margin="7,0,0,0"
                              Width="15"
                              Height="15"
                              Click="summaryButton_Click"
                              VerticalAlignment="Top"
                              ToolTip="Lock/unlock panel" />

                <TextBlock x:Name="sequenceSummaryLiteral"
                           Grid.Row="1"
                           VerticalAlignment="Center"
                           FontSize="16"
                           Text="Summary"
                           HorizontalAlignment="Center" />

                <TextBlock x:Name="sequencePropertyLiteral"
                           Grid.Row="1"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           FontSize="16"
                           Text="Hit Details"
                           Visibility="Collapsed" />

                <TextBlock x:Name="geneDetailsLiteral"
                           Grid.Row="1"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           FontSize="16"
                           Text="Gene Details"
                           Visibility="Collapsed" />

                <util:TabControl Grid.Row="2"
                                 TabStripPlacement="Bottom"
                                 x:Name="infoContainer"
                                 BorderThickness="1"
                                 SelectionChanged="infoContainer_SelectionChanged"
                                 Margin="10,0"
                                 Style="{DynamicResource TabControlStyle1}">

                    <util:TabItem Header="Summary"
                                  x:Name="sequenceSummaryContainer"
                                  FontSize="12"
                                  BorderThickness="1"
                                  Style="{DynamicResource TabItemStyle1}">

                        <silvermap:SequenceSummaryTable x:Name="sequenceSummaryTable"
                                                        VerticalAlignment="Stretch"
                                                        Foreground="Black" />
                    </util:TabItem>

                    <util:TabItem Header="Hit details"
                                  FontSize="12"
                                  x:Name="sequencePropertyContainer"
                                  BorderThickness="1"
                                  Style="{DynamicResource TabItemStyle1}">

                        <silvermap:SequencePropertyPanel x:Name="sequencePropertyPanel"
                                                         Foreground="Black" />
                    </util:TabItem>

                    <util:TabItem Header="Gene details"
                                  x:Name="geneDetailsContainer"
                                  Visibility="Collapsed"
                                  FontSize="12"
                                  BorderThickness="1"
                                  Style="{DynamicResource TabItemStyle1}"
                                  Foreground="Black">

                        <Grid x:Name="geneDetailsPanel" />
                    </util:TabItem>

                </util:TabControl>
                
                <Thumb x:Name="summaryThumb"
                       Margin="0"
                       DragDelta="summaryThumb_DragDelta"
                       Width="5"
                       Height="{Binding ActualHeight, ElementName=alignmentExpander}"
                       HorizontalAlignment="Left"
                       Grid.RowSpan="3"
                       Cursor="SizeWE"
                       HorizontalContentAlignment="Right"
                       VerticalContentAlignment="Stretch"
                       IsTabStop="False" />

            </Grid>
        </Expander>
    </Grid>
</UserControl>